/*
 * @Author: wuzhen
 * @Date: 2019-12-03 14:04:34
 * @LastEditors  : wuzhen
 * @LastEditTime : 2020-01-06 09:33:03
 * @Description: 入口
 */
import Vue from "vue";
import App from "./App.vue";
import router from "@/router";
import store from "./store";
import config from "@/config";
// 配置主题
import theme from "@/config/setting";
import VueI18n from "vue-i18n"; //国际化
import langOptions from "@/assets/i18n";
import ViewUI from "view-design";
import "@/iview-theme/index.less";
import WzIcon from "vue-svg-icon/Icon.vue";
// 引入 v-charts
import VCharts from "v-charts";
// moment日期格式化
import moment from "moment";
// lodash
import _ from "lodash";
// 自定义全局指令
import directive from "@/directive";
// 自定义全局组件
import components from "@/components";
// 自定义全局过滤器
import * as filters from "@/filters";

Vue.component("WzIcon", WzIcon);

Vue.config.productionTip = false;
// 全局注册应用配置
Vue.prototype.$config = config;
// 全局配置主题
Vue.prototype.$theme = theme;
// 全局配置日期格式化
Vue.prototype.$fmtMoment = (date, format) => {
  if (date) {
    return moment(date).format(format || "YYYY-MM-DD HH:mm:ss");
  }
  return null;
};
Vue.prototype.$_ = _;
// 全局注册中间件传值
Vue.prototype.$bus = new Vue();
Vue.use(ViewUI);
// 注册全局自定义指令
Vue.use(directive);
// 注册全局组件
Vue.use(components);
// 注册全局v-charts
Vue.use(VCharts);
// 注册全局过滤器
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key]);
});
// 国际化
Vue.use(VueI18n);
const i18n = new VueI18n(langOptions);

new Vue({
  router,
  store,
  i18n,
  render: h => h(App)
}).$mount("#app");
